package com.cx.mapper;

import com.cx.dto.TaskDTO;
import com.cx.dto.TaskPageDTO;
import com.cx.pojo.Project;
import com.cx.pojo.Task;
import com.cx.vo.CommonVO;
import com.cx.vo.TaskVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface TaskMapper {
    int addTask(TaskDTO taskDTO);

    @Select("select * from task where id = #{id}")
    TaskVO selectTaskById(Integer id);

    int updateTaskById(TaskDTO taskDTO);

    Page<Task> pageQuery(TaskPageDTO taskPageDTO);

    @Update("update task set status = #{status} where id = #{id}")
    void updateStatusById(@Param("id") Integer id, @Param("status") Integer status);

    @Delete("delete from task where id = #{id}")
    int deleteTaskById(Integer id);


    @Select("select * from task where status < #{status} and  end_time < #{time}")
    List<Task> getByStatusAndTimeProjectTimeLT(@Param("status") Integer status, @Param("time") LocalDateTime time);


    void update(Task task);

    @Select("select p.name name,t.task_name pOt from project p,task t where t.project_id = p.id")
    List<CommonVO> selectProjectOfTask();

    @Select("select * from task where project_id = #{id}")
    List<Task> selectTaskByProjectId(Integer id);
}
